#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=1e5+5;
int n,a[Maxn],b[Maxn],du[Maxn],root;
int head[Maxn],to[Maxn<<1],nxt[Maxn<<1],cnt1;
inline void add(int u,int v){
	to[++cnt1]=v;nxt[cnt1]=head[u];head[u]=cnt1;
}
int pd;
void dfs(int u,int v){
	if(pd==0)return;
	b[u]=0;priority_queue<int>heap;
	for(int i=head[u];i;i=nxt[i]){
		int y=to[i];
		if(y==v)continue;
		dfs(y,u);
		b[u]+=b[y];
	}
	if(du[u]==1)b[u]=a[u];
	else{
		if(b[u]/2+b[u]%2!=a[u])pd=0;
		b[u]=b[u]%2;
	}
//	if(du[u]!=1)b[u]-=a[u];
//	printf("%d:%d %d\n",u,b[u],a[u]);
}
inline void solve(){
	pd=1;
	memset(head,0,sizeof head);
	cnt1=0;memset(du,0,sizeof du);
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		du[u]++;du[v]++;
		add(u,v);add(v,u);
	}
	for(int i=1;i<=n;i++)
		if(du[i]>1)root=i;
	dfs(root,0);
	if(!pd)puts("NO");
	else puts("YES");
//	else if(b[root]==0)puts("YES");
//	else puts("NO");
}
signed main(){
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	//ios::sync_with_stdio(0);
	//cin.tie(0);//cout.tie(0);
	int T=read();
	while(T--)solve();
	return 0;
}

